package com.catjiu.office.service.impl;

import com.catjiu.office.entity.DocInfo;
import com.catjiu.office.service.OfficeService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.print.Doc;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * <br>类描述：
 * <br>author： lwl liuwanli_eamil@163.com	2020/8/27 17:15
 *
 * @ClassName OfficeServiceImpl
 * @see #
 * @since {修改人、修改时间、修改事由}
 */
@Service
public class OfficeServiceImpl implements OfficeService {
    @Value("${doc.save.path.store}")
    private String upload_file_path;

    @Override
    public List<DocInfo> list() {
        //这里偷个懒，就不存到数据库了
        File folder = new File(upload_file_path);
        File[] files = folder.listFiles();
        if(files!=null && files.length>0){
            List<DocInfo> docInfos = new ArrayList<>(files.length);
            for(File file:files){
                DocInfo docInfo = new DocInfo();
                docInfo.setFileName(file.getName());
                docInfos.add(docInfo);
            }
            return docInfos;
        }
        return null;
    }

    @Override
    public void save(DocInfo docInfo) {

    }
}
